﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FB.DataAccess;

namespace FB.Videos.ucCommon
{
    public partial class ucVideoList : System.Web.UI.UserControl
    {
        public IEnumerable<Video> VideoList { get; set; }
        public int NumberDisplay { get; set; }
        public string TitleDisplay { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadData();
            }
        }

        private void LoadData()
        {
            if (TitleDisplay.ToString() != string.Empty)
            {
                lblTitle.Text = TitleDisplay;
                lblTitle.Visible = true;
            }

            if (VideoList != null)
            {
                if (VideoList.Count() > 0)
                {
                    rptData.DataSource = VideoList.Select(v => v).Take(NumberDisplay);
                    rptData.DataBind();
                }
                else
                {
                    lblMsg.Text = "Không có video nào !";
                    lblMsg.Visible = true;
                }
            }
        }
    }
}